<form action="?act=8" name="frmxlEditDMSP" method="post">
<table width="100%" class="XuLy" >
<?php
	include("../lib/DataProvider.php");
	if(isset($_GET['sk']))
	{
		$sk=$_GET['sk'];
		switch ($sk)
		{
			case 1:
				?>
				<tr>
					<td colspan="2" class="center">Thêm Nhà Sản Xuất</td>
				</tr>
				<tr>
					<td class="canphai">Tên NSX:</td>
					<td><input name="txtTenHSX" type="text" id="txtTenHSX" size="30"></td>
				</tr>
				<tr>
					<td class="canphai">Địa Chỉ:</td>
					<td><input name="txtDiaChi" type="text" id="txtDiaChi" size="30"></td>
				</tr>
				<tr>
					<td></td>
					<td >
						<input type="submit" name="btnThemHSX" id="btnThemHSX" value="Thêm">
						<input type="reset" name="btnReset" value="Làm mới">
						<input type="button" name="btnHuy" value="Huỷ bỏ" onclick="HuyEditDMSP()">
					</td>
				</tr>
				
				<?php 
				break;
			case 2:
				if(isset($_GET['ID']))
				{
					$MaHSX=$_GET['ID'];
					$ds=DataProvider::ExecuteQuery("select * from hangsanxuat where MAHSX='".$MaHSX."'");
					?>
					<tr>
						<td colspan="2" class="center">Sửa thông tin nhà sản xuất</td>
					</tr>
					<?php 
					while($row = mysql_fetch_array($ds,MYSQL_ASSOC))
					{?>
						<tr>
						<td class="canphai">Mã NSX:</td>
						<td><?php echo $MaHSX;?></td>
						<input type="hidden" name="txtMaHSX1" id="txtMaHSX1" value="<?php echo $MaHSX;?>">
						</tr>
						<tr>
							<td class="canphai">Tên NSX:</td>
							<td><input type="text" name="txtTenHSX" id="txtTenHSX" value="<?php echo $row['TENHSX'];?>"></td>
						</tr>
						<tr>
							<td class="canphai">Địa chỉ:</td>
							<td><input type="text" name="txtDiaChi" id="txtDiaChi" value="<?php echo $row['DIACHI'];?>"></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="checkbox" name="cbBiXoa1" id="cbBiXoa1" <?php if($row['BIXOA']==1) echo "checked='checked'";?>>
							Bị xoá</td>
						</tr>
						<tr>
							<td></td>
							<td><input type="submit" name="btnCapNhatHSX" id="btnCapNhatHSX" value="Cập nhật" />
								<input type="reset" name="btnReset" id="btnReset" value="Làm mới" />
								<input type="button" name="btnHuy" id="btnHuy" value="Huỷ" onclick="HuyEditDMSP()"/>
							</td>
						</tr>
					<?php }
				}
				break;
			case 3: 
				if(isset($_GET['ID']))
				{
					$MaHSX=$_GET['ID'];
					$ds1=DataProvider::ExecuteQuery("select * from sanpham where MAHSX=".$MaHSX);
					$ds2=DataProvider::ExecuteQuery("select * from loaisanpham where MAHSX=".$MaHSX);
					if(mysql_num_rows($ds1)>0 || mysql_num_rows($ds2)>0)
					{						
						$update=DataProvider::ExecuteQuery("update hangsanxuat set BIXOA=1 where MAHSX='".$MaHSX."'");
						echo '<div class="center"><b>Nhà sản xuất này đã có sản phẩm! Chúng ta sẽ dánh dấu xoá.</b></div>';
					?>
						<head>
						<meta http-equiv="refresh" content="2; url=?act=3" />
						</head>
					<?php
					}else{
						$delete1=DataProvider::ExecuteQuery("delete from hangsanxuat where MAHSX='".$MaHSX."'");
						echo '<div class="center"><b>Xoá thành công!</b></div>';
						?>
							<head>
							<meta http-equiv="refresh" content="2; url=?act=3" />
							</head>
						<?php
					}
				}
				break;
			case 4: 
				?>
				<tr>
					<td colspan="2" class="center">Thêm loại sản phẩm</td>
				</tr>
				<tr>
					<td class="canphai">Tên LSP:</td>
					<td><input name="txtTenLSP" type="text" id="txtTenLSP" size="30"></td>
				</tr>
				<tr>
					<td class="canphai">Mã NSX:</td>
					<td><input name="txtMaHSX" type="text" id="txtMaHSX" size="30"></td>
				</tr>
				<tr>
					<td></td>
					<td >
						<input type="submit" name="btnThemLSP" id="btnThemLSP" value="Thêm">
						<input type="reset" name="btnReset" value="Làm mới">
						<input type="button" name="btnHuy" value="Huỷ bỏ" onclick="HuyEditDMSP()">
					</td>
				</tr>
				
				<?php 
				break;
			case 5: 
				if(isset($_GET['ID']))
				{
					$MaLSP=$_GET['ID'];
					$ds=DataProvider::ExecuteQuery("select * from loaisanpham where MALSP='".$MaLSP."'");
					?>
					<tr>
						<td colspan="2" class="center">Sửa thông tin loại sản phẩm</td>
					</tr>
					<?php 
					while($row = mysql_fetch_array($ds,MYSQL_ASSOC))
					{?>
						<tr>
						<td class="canphai">Mã LSP:</td>
						<td><?php echo $MaLSP;?></td>
						<input type="hidden" name="txtMaLSP" id="txtMaLSP" value="<?php echo $MaLSP;?>">
						</tr>
						<tr>
							<td class="canphai">Tên LSP:</td>
							<td><input type="text" name="txtTenLSP" id="txtTenLSP" value="<?php echo $row['TENLSP'];?>"></td>
						</tr>
						<tr>
							<td class="canphai">Mã NSX:</td>
							<td><input type="text" name="txtMaHSX2" id="txtMaHSX2" value="<?php echo $row['MAHSX'];?>"></td>
						</tr>
						<tr>
							<td></td>
							<td><input type="checkbox" name="cbBiXoa2" id="cbBiXoa2" <?php if($row['BIXOA']==1) echo "checked='checked'";?>>
							Bị xoá</td>
						</tr>
						<tr>
							<td></td>
							<td><input type="submit" name="btnCapNhatLSP" id="btnCapNhatLSP" value="Cập nhật" />
								<input type="reset" name="btnReset" id="btnReset" value="Làm mới" />
								<input type="button" name="btnHuy" id="btnHuy" value="Huỷ" onclick="HuyEditDMSP()"/>
							</td>
						</tr>
					<?php }
				}
				break;
			case 6: 
			if(isset($_GET['ID']))
			{
				$MaLSP=$_GET['ID'];
				$ds1=DataProvider::ExecuteQuery("select * from sanpham where MALSP='".$MaLSP."'");
				$ds2=DataProvider::ExecuteQuery("select * from cauhinh where MALSP='".$MaLSP."'");
				if(mysql_num_rows($ds1)>0 || mysql_num_rows($ds2)>0)
				{						
					$update=DataProvider::ExecuteQuery("update loaisanpham set BIXOA=1 where MALSP='".$MaLSP."'");
					echo '<div class="center"><b>Loại sản phẩm này đã có sản phẩm! Chúng ta sẽ dánh dấu xoá.</b></div>';
				?>
					<head>
					<meta http-equiv="refresh" content="2; url=?act=3" />
					</head>
				<?php
				}else{
					$delete1=DataProvider::ExecuteQuery("delete from loaisanpham where MALSP='".$MaLSP."'");
					echo '<div class="center"><b>Xoá thành công!</b></div>';
					?>
						<head>
						<meta http-equiv="refresh" content="2; url=?act=3" />
						</head>
					<?php
				}
			break;
			}
		}
	}
?>